/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uit.tkorg.and.gui;

import java.awt.Frame;
import java.io.File;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import uit.tkorg.and.models.Vector;
import javax.swing.ButtonGroup;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
import uit.tkorg.and.models.Feature;
import uit.tkorg.and.models.MachineLearning;
import uit.tkorg.and.models.PairPublication;
import weka.classifiers.Evaluation;
import weka.core.Instances;
import weka.core.Utils;

/**
 *
 * @author tiendv
 */
public class OldWithCrossValidate extends javax.swing.JFrame {
    private PairPublication[] data;
    private Instances train;
    private Instances test;
    /**
     * Creates new form Main
     */
    public OldWithCrossValidate() {
        initComponents();
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        tfTrainingDataParth = new javax.swing.JTextField();
        tfTestDataParth = new javax.swing.JTextField();
        btTrainingDataParth = new javax.swing.JButton();
        btTestDataParth = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        cbJaccardAuthorName = new javax.swing.JCheckBox();
        cbJaccardAfiliation = new javax.swing.JCheckBox();
        cbJaccardCoAuthor = new javax.swing.JCheckBox();
        cbJaccardKeyword = new javax.swing.JCheckBox();
        cbJaccardKeyInteresting = new javax.swing.JCheckBox();
        cbLevenshteinAuthorName = new javax.swing.JCheckBox();
        cbLevenshteinAfflicaiton = new javax.swing.JCheckBox();
        cbJaroAuthorName = new javax.swing.JCheckBox();
        cbJarodAfiliation = new javax.swing.JCheckBox();
        cbJaroWinklerAuthorName = new javax.swing.JCheckBox();
        cbJaroWinklerAffiliaiton = new javax.swing.JCheckBox();
        cbSmithWatermanAuthorName = new javax.swing.JCheckBox();
        cbSmithWatermanAffiliation = new javax.swing.JCheckBox();
        cbMongeElkanAuthorName = new javax.swing.JCheckBox();
        cbMongeElkanAffiliaiton = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        rbRF = new javax.swing.JRadioButton();
        rbSVM = new javax.swing.JRadioButton();
        rbBayes = new javax.swing.JRadioButton();
        rbc45 = new javax.swing.JRadioButton();
        rdKNN = new javax.swing.JRadioButton();
        btRun = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        taLog = new javax.swing.JTextArea();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Data"));

        jLabel1.setText("Dateset Folder:");

        jLabel2.setText("Test Data");
        jLabel2.setEnabled(false);

        tfTestDataParth.setEditable(false);

        btTrainingDataParth.setText("Open");
        btTrainingDataParth.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btTrainingDataParthActionPerformed(evt);
            }
        });

        btTestDataParth.setText("Open");
        btTestDataParth.setEnabled(false);
        btTestDataParth.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btTestDataParthActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(tfTestDataParth)
                    .addComponent(tfTrainingDataParth, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btTrainingDataParth)
                    .addComponent(btTestDataParth))
                .addContainerGap(121, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(tfTrainingDataParth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btTrainingDataParth))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tfTestDataParth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btTestDataParth))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Features"));

        cbJaccardAuthorName.setText("JCAuthorName");

        cbJaccardAfiliation.setText("JCAffiliation ");

        cbJaccardCoAuthor.setText("JCCoAuthor");

        cbJaccardKeyword.setText("JCKeyWord");

        cbJaccardKeyInteresting.setText("JCKeyInteresting");

        cbLevenshteinAuthorName.setText("LevenshteinAuthorName");
        cbLevenshteinAuthorName.setToolTipText("");
        cbLevenshteinAuthorName.setEnabled(false);

        cbLevenshteinAfflicaiton.setText("LevenshteinAffiliation");
        cbLevenshteinAfflicaiton.setEnabled(false);

        cbJaroAuthorName.setText("JaroAuthorName");
        cbJaroAuthorName.setEnabled(false);

        cbJarodAfiliation.setText("JaroAffiliation ");
        cbJarodAfiliation.setEnabled(false);

        cbJaroWinklerAuthorName.setText("JaroWinklerAuthorName");
        cbJaroWinklerAuthorName.setEnabled(false);

        cbJaroWinklerAffiliaiton.setText("JaroWinklerAffiliaiton");
        cbJaroWinklerAffiliaiton.setEnabled(false);

        cbSmithWatermanAuthorName.setText("SmithWatermanAuthorName");
        cbSmithWatermanAuthorName.setEnabled(false);

        cbSmithWatermanAffiliation.setText("SmithWatermanAffiliation");
        cbSmithWatermanAffiliation.setEnabled(false);

        cbMongeElkanAuthorName.setText("MongeElkanAuthorName");
        cbMongeElkanAuthorName.setEnabled(false);

        cbMongeElkanAffiliaiton.setText("MongeElkanAffiliaiton");
        cbMongeElkanAffiliaiton.setEnabled(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbJaccardAuthorName)
                    .addComponent(cbJaroWinklerAffiliaiton)
                    .addComponent(cbJaroWinklerAuthorName)
                    .addComponent(cbJarodAfiliation)
                    .addComponent(cbJaroAuthorName)
                    .addComponent(cbLevenshteinAfflicaiton)
                    .addComponent(cbLevenshteinAuthorName)
                    .addComponent(cbJaccardKeyInteresting)
                    .addComponent(cbJaccardKeyword)
                    .addComponent(cbJaccardCoAuthor)
                    .addComponent(cbJaccardAfiliation))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbSmithWatermanAuthorName)
                    .addComponent(cbSmithWatermanAffiliation)
                    .addComponent(cbMongeElkanAuthorName)
                    .addComponent(cbMongeElkanAffiliaiton))
                .addContainerGap(65, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbJaccardAuthorName)
                    .addComponent(cbSmithWatermanAuthorName))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbJaccardAfiliation)
                    .addComponent(cbSmithWatermanAffiliation))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbJaccardCoAuthor)
                    .addComponent(cbMongeElkanAuthorName))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbJaccardKeyword)
                    .addComponent(cbMongeElkanAffiliaiton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbJaccardKeyInteresting)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbLevenshteinAuthorName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbLevenshteinAfflicaiton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbJaroAuthorName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbJarodAfiliation)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbJaroWinklerAuthorName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbJaroWinklerAffiliaiton)
                .addContainerGap(15, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Classifiers"));

        buttonGroup1.add(rbRF);
        rbRF.setText("Random Forest");

        buttonGroup1.add(rbSVM);
        rbSVM.setText("SVM");

        buttonGroup1.add(rbBayes);
        rbBayes.setText("Bayes");

        buttonGroup1.add(rbc45);
        rbc45.setText("C4.5");

        buttonGroup1.add(rdKNN);
        rdKNN.setText("KNN");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rbRF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rbSVM)
                .addGap(10, 10, 10)
                .addComponent(rbBayes)
                .addGap(18, 18, 18)
                .addComponent(rbc45)
                .addGap(18, 18, 18)
                .addComponent(rdKNN)
                .addContainerGap(74, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rbRF)
                    .addComponent(rbSVM)
                    .addComponent(rbBayes)
                    .addComponent(rbc45)
                    .addComponent(rdKNN))
                .addContainerGap(9, Short.MAX_VALUE))
        );

        btRun.setText("RUN");
        btRun.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRunActionPerformed(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Log"));

        taLog.setColumns(20);
        taLog.setRows(5);
        jScrollPane1.setViewportView(taLog);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 492, Short.MAX_VALUE)
                .addContainerGap())
        );

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(btRun, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(14, 14, 14))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btRun, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btTrainingDataParthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btTrainingDataParthActionPerformed
        // TODO add your handling code here:
        

        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        fc.showOpenDialog(this);  
        // Show open dialog; this method does not return until the dialog is closed       
        tfTrainingDataParth.setText(fc.getSelectedFile().getAbsolutePath());
    }//GEN-LAST:event_btTrainingDataParthActionPerformed

    private void btTestDataParthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btTestDataParthActionPerformed
        // TODO add your handling code here:
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        fc.showOpenDialog(this);  
        // Show open dialog; this method does not return until the dialog is closed       
        tfTestDataParth.setText(fc.getSelectedFile().getAbsolutePath());
    }//GEN-LAST:event_btTestDataParthActionPerformed

    private void btRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRunActionPerformed
        try {                                      
                // TODO add your handling code here:
                // Get path data

                String pathForTrain = tfTrainingDataParth.getText();
                String pathForTest = tfTestDataParth.getText();

                //Get Feature

                Feature selectFeatures = new Feature();
                int dimension =0;

                // Jaccard Authorname
                if(cbJaccardAuthorName.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJcAuthorName(true);
                }
                // Jaccard Coauthor 
                if(cbJaccardCoAuthor.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJcCoAuthor(true);
                }
                  // Jaccard Afiliation
                if(cbJaccardAfiliation.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJcAffiliation(true);
                }
                  // Jaccard keword
                if(cbJaccardKeyword.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJcKeyword(true);
                }
                  // Jaccard Interesting
                if(cbJaccardKeyInteresting.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJcInterestingKeyword(true);
                }

                  // Levenshtein Author name
                if(cbLevenshteinAuthorName.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setLevenshteinAuthorname(true);
                }
                  // Levenshtein Affilication
                if(cbLevenshteinAfflicaiton.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setLevenshteinAffiliaiton(true);
                }    
                // Jaro Author Name
                if(cbJaroAuthorName.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJaroAuthorName(true);
                }            
                // Jarro Affilication
                if(cbJarodAfiliation.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJaroAffiliation(true);
                }  
                // Jarro Winkler AuthorName
                if(cbJaroWinklerAuthorName.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJarowinklerAuthorName(true);
                }
                 // Jarro Winkler Affiliaction 
                if(cbJaroWinklerAffiliaiton.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setJarowinklerAffiliaiton(true);
                }
                // SmithWaterman AuthorName
                if(cbSmithWatermanAuthorName.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setSmithWatermanAuthorName(true);
                }
               // SmithWaterman Author Affiliaiton
                if(cbSmithWatermanAffiliation.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setSmithWatermanAffiliation(true);
                }
               // Monge-Elkan Author Name
                if(cbMongeElkanAuthorName.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setMongeElkanAuthorName(true);
                }
                // Monge-Elkan Author Affiliation
                if(cbMongeElkanAffiliaiton.isSelected())
                {
                    dimension ++;
                    selectFeatures.setNumberSelectFeature(dimension);
                    selectFeatures.setMongeElkanAffiliation(true);
                }

                // Add more feature here   

                // Get Classifier
                JRadioButton nameClassifier = getSelection(buttonGroup1);
                String name = nameClassifier.getText();
                OldWithCrossValidate.taLog.append("Classifier: " + name);
                OldWithCrossValidate.taLog.append("\n");
                MachineLearning mc = null;
                if(name.equals("Random Forest"))
                    mc = new MachineLearning(MachineLearning.TypeClassifier.RF);
                if(name.equals("SVM"))
                    mc = new MachineLearning(MachineLearning.TypeClassifier.SVM);
                if(name.equals("Bayes"))
                    mc = new MachineLearning(MachineLearning.TypeClassifier.BY);
                if(name.equals("C4.5"))
                    mc = new MachineLearning(MachineLearning.TypeClassifier.C45);
                if(name.equals("KNN"))
                    mc = new MachineLearning(MachineLearning.TypeClassifier.KNN);

                
                //Load data:
                //PairPublication[] pair = Vector.buildVectorsFromFolderPairPublication(pathForTrain);
                
                String testCrossPath = "\\test";
                String trainCrossPath = "\\train";
                
                PairPublication[] pairTest = null;
                PairPublication[] pairTrain = null;
                
                //data = this.doubleListPairPublication(pair);

                //int unit = pair.length / 10;

//                int start = 0;
//                int end = 0;

                int loop = 1;
                while(loop <= 10)
                {
                    //<editor-fold defaultstate="collapsed" desc="Old code">
//                    System.out.println("==========LOOP:"+ (loop + 1) +"=========");
//                    Main.taLog.append("==========LOOP:"+ (loop + 1) +"=========");
//                    Main.taLog.append("\n");
//                    start = loop * unit;
//                    end = (int)((float)unit * 6) + start;    
//                    //System.out.println("==========TRAIN=========");
//                    train = Vector.buildVectorTrain(data, selectFeatures, start, end); 
//                    
//                    //System.out.println("==========END-TRAIN=========");
//                    //System.out.println("==========TEST=========");
//                    if(end <= pair.length){                    
//                        test = Vector.buildVectorTest(pair, selectFeatures, start, end);
//                    }
//                    else {
//                        test = Vector.buildVectorTrain(pair, selectFeatures, end - pair.length, start);
//                    } 
                    //System.out.println("==========END-TEST=========");
                    //</editor-fold>
                    
                    testCrossPath = pathForTrain + "\\" + loop + "\\" + "test\\";
                    trainCrossPath = pathForTrain + "\\" + loop + "\\" + "train\\";
                    
                    pairTest = Vector.buildVectorsFromFolderPairPublication(testCrossPath);    
                    pairTrain = Vector.buildVectorsFromFolderPairPublication(trainCrossPath);   
                    
                    test = Vector.buildVector(pairTest, selectFeatures);
                    train = Vector.buildVector(pairTrain, selectFeatures);

                    mc.cModel.buildClassifier(train);
                    Evaluation eTest = new Evaluation(test);
                    eTest.evaluateModel(mc.cModel, test);
                    
                    System.out.println("Result : ");                    
                    System.out.println(eTest.toMatrixString());
                    System.out.println(eTest.toSummaryString());  
                    
                    OldWithCrossValidate.taLog.append("Result : ");
                    OldWithCrossValidate.taLog.append("\n");
                    OldWithCrossValidate.taLog.append(eTest.toMatrixString());
                    OldWithCrossValidate.taLog.append("\n");
                    OldWithCrossValidate.taLog.append(eTest.toSummaryString());
                    OldWithCrossValidate.taLog.append("Total Number of Instance For Train : " + train.numInstances());
                    OldWithCrossValidate.taLog.append("\n");
                    loop++;
                    
                    test = null;
                    train = null;
                    
                    pairTest.clone();
                    pairTrain.clone();
                }
         } catch (Exception ex) {
            taLog.append(OldWithCrossValidate.class.getName() + " -EXCEPTION: " + ex.getMessage());
        }         
    }//GEN-LAST:event_btRunActionPerformed
    
    public PairPublication[] doubleListPairPublication(PairPublication[] pairList)
    {
        PairPublication[] list = new PairPublication[pairList.length * 2];        
        for(int i = 0; i < pairList.length; i++)
        {
            list[i] = pairList[i];
            list[i + pairList.length] = pairList[i];
        }        
        return list;
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(OldWithCrossValidate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(OldWithCrossValidate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(OldWithCrossValidate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(OldWithCrossValidate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new OldWithCrossValidate().setVisible(true);
            }
        });
    }
    public static JRadioButton getSelection(ButtonGroup group) {
    for (Enumeration e=group.getElements(); e.hasMoreElements(); ) {
        JRadioButton b = (JRadioButton)e.nextElement();
        if (b.getModel() == group.getSelection()) {
            return b;
        }
    }
    return null;
}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btRun;
    private javax.swing.JButton btTestDataParth;
    private javax.swing.JButton btTrainingDataParth;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JCheckBox cbJaccardAfiliation;
    private javax.swing.JCheckBox cbJaccardAuthorName;
    private javax.swing.JCheckBox cbJaccardCoAuthor;
    private javax.swing.JCheckBox cbJaccardKeyInteresting;
    private javax.swing.JCheckBox cbJaccardKeyword;
    private javax.swing.JCheckBox cbJaroAuthorName;
    private javax.swing.JCheckBox cbJaroWinklerAffiliaiton;
    private javax.swing.JCheckBox cbJaroWinklerAuthorName;
    private javax.swing.JCheckBox cbJarodAfiliation;
    private javax.swing.JCheckBox cbLevenshteinAfflicaiton;
    private javax.swing.JCheckBox cbLevenshteinAuthorName;
    private javax.swing.JCheckBox cbMongeElkanAffiliaiton;
    private javax.swing.JCheckBox cbMongeElkanAuthorName;
    private javax.swing.JCheckBox cbSmithWatermanAffiliation;
    private javax.swing.JCheckBox cbSmithWatermanAuthorName;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JRadioButton rbBayes;
    private javax.swing.JRadioButton rbRF;
    private javax.swing.JRadioButton rbSVM;
    private javax.swing.JRadioButton rbc45;
    private javax.swing.JRadioButton rdKNN;
    public static javax.swing.JTextArea taLog;
    private javax.swing.JTextField tfTestDataParth;
    private javax.swing.JTextField tfTrainingDataParth;
    // End of variables declaration//GEN-END:variables
}
